<?php
/**
 * Created by PhpStorm.
 * User: 刘凯龙
 * Date: 2018/9/3
 * Time: 10:37
 */
use yii\helpers\Html;
use yii\grid\GridView;
use \yii\helpers\Url;

/* @var $this yii\web\View */
/* @var $searchModel backend\models\AdminUserSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */

$this->title = 'Users';
$this->params[ 'breadcrumbs' ][] = $this->title;
?>
<div class = "wrapper wrapper-content animated fadeInRight">
    <div class = "row">
        <div class = "col-sm-12">
            <div class = "ibox float-e-margins">
                <div class = "ibox-title">
                    <a class = "btn btn-sm btn-success" href = "<?= Url::to( [
                        'create' ,
                    ] ) ?>"><i class = "fa fa-plus"></i>&nbsp;&nbsp;<span>创建账号</span></a>
                </div>
                <div class = "ibox-content">
                    <div class = "table-responsive">
                        <?= GridView::widget( [
                            'dataProvider'  => $dataProvider ,
                            'filterModel'   => $searchModel ,
                            'layout'        => '{summary}{items}<div class="text-right tooltip-demo">{pager}</div>' ,
                            'rowOptions'    => [ 'class' => 'text-center' ] ,
                            'pager'         => [
                                'firstPageLabel' => "首页" ,
                                'prevPageLabel'  => '上一页' ,
                                'nextPageLabel'  => '下一页' ,
                                'lastPageLabel'  => '尾页' ,
                            ] ,
                            'columns'       => [
                                [ 'class' => 'yii\grid\SerialColumn', 'headerOptions' => [ 'style'=>['width' => '60','color'=>'#337ab7']] ,] ,
                                'name',
                                'mobile_phone' ,
                                'username' ,
                                'last_time',
                                [
                                    'header'        => '操作',
                                    'class'         => 'yii\grid\ActionColumn' ,
                                    'template'      => '{update}  {auth} {delete}' ,
                                    'headerOptions' => [ 'style'=>['width' => '60','color'=>'#337ab7']] ,
                                    'buttons'       => [
                                        'update' => function ( $url , $model , $key ) {
                                                return Html::a( '修改资料' , [
                                                    'update' ,
                                                    'id' => $model->id ,
                                                ] , [ 'class' => "btn btn-xs btn-success" ] );
                                        } ,
                                        'delete' => function ( $url , $model , $key ) {
                                                 return Html::a('删除', [
                                                     'delete',
                                                     'id' => $model->id,
                                                 ], [
                                                     'class' => "btn btn-xs btn-danger",
                                                     'data' => [
                                                         'confirm' => '确定要刪除吗？',
                                                         'method' => 'post',
                                                     ],
                                                 ]);
                                        } ,
                                    ] ,
                                ] ,
                            ] ,
                        ] ); ?>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
